package cn.com.charles.influxdb.entity;

import org.influxdb.annotation.Column;
import org.influxdb.annotation.Measurement;

import com.alibaba.fastjson.JSON;

/**
 * InfluxDB中,measurement对应于传统关系型数据库中的table(database为配置文件中的log_management). InfluxDB里存储的数据称为时间序列数据,时序数据有零个或多个数据点.
 * 数据点包括time(一个时间戳)，measurement(例如logInfo)，零个或多个tag，其对应于level,module,device_id),至少一个field(即日志内容,msg=something error).
 * InfluxDB会根据tag数值建立时间序列(因此tag数值不能选取诸如UUID作为特征值,易导致时间序列过多,导致InfluxDB崩溃),并建立相应索引,以便优化诸如查询速度.
 */
@Measurement(name = "trackpoint")
public class TrackPoint {
	@Column(name = "time")
	private double time;

	@Column(name = "cpuid", tag = true)
	private String cpuid;

	@Column(name = "cputype", tag = true)
	private String cputype;

	@Column(name = "lat")
	private float lat;

	@Column(name = "lon")
	private float lon;

	@Column(name = "state")
	private String state;

	@Override
	public String toString() {
		return JSON.toJSONString(this);
	}

	public double getTime() {
		return time;
	}

	public void setTime(double time) {
		this.time = time;
	}

	public String getCpuid() {
		return cpuid;
	}

	public void setCpuid(String cpuid) {
		this.cpuid = cpuid;
	}

	public String getCputype() {
		return cputype;
	}

	public void setCputype(String cputype) {
		this.cputype = cputype;
	}

	public float getLat() {
		return lat;
	}

	public void setLat(float lat) {
		this.lat = lat;
	}

	public float getLon() {
		return lon;
	}

	public void setLon(float lon) {
		this.lon = lon;
	}

	public String getState() {
		return state;
	}

	public void setState(String state) {
		this.state = state;
	}

}
